<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>JSTL format Tag</title>
		<style type="text/css">
li {
	display: inline;
}

ul {
	list-style-type: disc;
}
</style>
	</head>
	<body>
		<fmt:requestEncoding value="UTF-8" />
		<fmt:setBundle basename="appresource" />
		法国数字格式:
		<fmt:setLocale value="fr_fr" />
		<ul>
			<li>
				&nbsp;&nbsp;
				<fmt:formatNumber value="123456789.012" />
			</li>
			<li>
				&nbsp;&nbsp;
				<fmt:formatNumber value="0.3" type="number" />
			</li>
			<li>
				&nbsp;&nbsp;
				<fmt:formatNumber value="0.3" type="currency" />
			</li>
			<li>
				&nbsp;&nbsp;
				<fmt:formatNumber value="0.3" type="percent" />
			</li>
			<li>
				&nbsp;&nbsp;
				<fmt:formatDate value="<%=new Date()%>" type="both" />
			</li>
		</ul>
		中国数字格式:
		<fmt:setLocale value="zh_CN" />
		<ul>
			<li>
				&nbsp;&nbsp;
				<fmt:formatNumber value="123456789.012" />
			</li>
			<li>
				&nbsp;&nbsp;
				<fmt:formatNumber value="0.3" type="number" />
			</li>
			<li>
				&nbsp;&nbsp;
				<fmt:formatNumber value="0.3" type="currency" />
			</li>
			<li>
				&nbsp;&nbsp;
				<fmt:formatNumber value="0.3" type="percent" />
			</li>
			<li>
				&nbsp;&nbsp;
				<fmt:formatDate value="<%=new Date()%>" type="both" />
			</li>
		</ul>
		
		德国数字格式:
		<fmt:setLocale value="de_de" />
		<ul>
			<li>
				&nbsp;&nbsp;
				<fmt:formatNumber value="123456789.012" />
			</li>
			<li>
				&nbsp;&nbsp;
				<fmt:formatNumber value="0.3" type="number" />
			</li>
			<li>
				&nbsp;&nbsp;
				<fmt:formatNumber value="0.3" type="currency" />
			</li>
			<li>
				&nbsp;&nbsp;
				<fmt:formatNumber value="0.3" type="percent" />
			</li>
			<li>
				&nbsp;&nbsp;
				<fmt:formatDate value="<%=new Date()%>" type="both" />
			</li>
		</ul>
		台湾数字格式:
		<fmt:setLocale value="zh_tw" />
		<ul>
			<li>
				&nbsp;&nbsp;
				<fmt:formatNumber value="123456789.012" />
			</li>
			<li>
				&nbsp;&nbsp;
				<fmt:formatNumber value="0.3" type="number" />
			</li>
			<li>
				&nbsp;&nbsp;
				<fmt:formatNumber value="0.3" type="currency" />
			</li>
			<li>
				&nbsp;&nbsp;
				<fmt:formatNumber value="0.3" type="percent" />
			</li>
			<li>
				&nbsp;&nbsp;
				<fmt:formatDate value="<%=new Date()%>" type="both" />
			</li>
		</ul>
		美国数字格式:
		<fmt:setLocale value="en_us" />
		<ul>
			<li>
				&nbsp;&nbsp;
				<fmt:formatNumber value="123456789.012" />
			</li>
			<li>
				&nbsp;&nbsp;
				<fmt:formatNumber value="0.3" type="number" />
			</li>
			<li>
				&nbsp;&nbsp;
				<fmt:formatNumber value="0.3" type="currency" />
			</li>
			<li>
				&nbsp;&nbsp;
				<fmt:formatNumber value="0.3" type="percent" />
			</li>
			<li>
				&nbsp;&nbsp;
				<fmt:formatDate value="<%=new Date()%>" type="both" />
			</li>
		</ul>
		自定义数字样式
		<ul>
			<li>
				12.31255Pattern 0000.000&nbsp;&nbsp;
				<fmt:formatNumber value="12.31255" pattern="0000.000" />
			</li>
			<li>
				&nbsp;&nbsp;1234.6545Pattern .##
				<fmt:formatNumber value="1234.6545" pattern=".##" />
			</li>
		</ul>
		parseNumber
		<ul>
			<li>
				&nbsp;&nbsp;#32.556转成数字:
				<fmt:parseNumber value="$32.556" type="currency" integerOnly="true"
					parseLocale="en_us" />
			</li>
		</ul>
		parseDate
		<ul>
			<li>
				<fmt:setLocale value="zh_cn" />
				&nbsp;&nbsp;
				<fmt:formatDate value="<%=new Date()%>" type="both" dateStyle="full"
					timeStyle="full" var="mytime" />
				<c:out value="${mytime}"></c:out>
			</li>
		</ul>
		fmt:message
		<ul>
			<li>
				<fmt:message  key="res.username" />:<fmt:message  key="res.gender" />
			</li>
		</ul>
		<fmt:formatDate value="<%=new Date()%>" type="both" pattern="yyyy年MM月dd日-HH时mm分ss秒" />
		<fmt:parseDate value="2012年06月17日-19时26分40秒" pattern="yyyy年MM月dd日-HH时mm分ss秒" var="myDate" scope="page" />
		<%out.print( pageContext.getAttribute("myDate") ); %>
	</body>
</html>

